package org.opentcs.strategies.basic.routing.jgrapht;

import jakarta.annotation.Nonnull;
import jakarta.inject.Inject;
import org.jgrapht.Graph;
import org.jgrapht.alg.interfaces.ShortestPathAlgorithm;
import org.opentcs.components.kernel.routing.Edge;
import org.opentcs.strategies.basic.routing.jgrapht.jjwcalg.FSYAStartShortPathAlg;
import org.opentcs.strategies.basic.scheduling.ReservationPool;

import static java.util.Objects.requireNonNull;

public class AStartPointRouterFactory extends AbstractPointRouterFactory {

  /**
   * 用户获取当前已经被分配的资源的状态。
   */
  private final ReservationPool reservationPool;

  /**
   * Create a new instance of the A* algorithm
   *
   * @param graphProvider Provides routing graphs for vehicles.
   */
  @Inject
  public AStartPointRouterFactory(@Nonnull GraphProvider graphProvider,
                                  ReservationPool reservationPool) {
    super(graphProvider);
    this.reservationPool = requireNonNull(reservationPool, "reservationPool");
  }

  @Override
  protected ShortestPathAlgorithm<String, Edge> createShortestPathAlgorithm(Graph<String, Edge> graph) {
    System.out.println("use a* alg");
    return new FSYAStartShortPathAlg<>(graph,reservationPool);
  }
}
